<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>连接测试：</div>
</body>
</html>
<script>
window.onload = function () {
  if (window.EventSource) {
    let chat = {sex: '1', nickName: '18810126510', fromUserName: '11'}
    // let url = `http://yxchat.impc.com.cn/vuechat/getConnection?channel=A&sex=${chat.sex}&nickName=${chat.nickName}&fromUserName=${chat.fromUserName}`
    let url="http://localhost:3000/demo/connectSee"
    const eventSource = new EventSource(url)
    console.log('EventSource1', eventSource)
    console.log('EventSource2', url)
    eventSource.addEventListener('open', function (e) {
      console.log('EventSource3', '连接打开')
    })
    eventSource.addEventListener('message', function (e) {
      console.log("EventSource4", e)
    })
    eventSource.addEventListener('error', function (e) {
      console.log("EventSource5", '连接断掉了')
      eventSource.close();
    })
  }

}
</script>
